#include<iostream>
#include<iomanip>
#include<string.h>
#include<cmath>
#include<stdio.h>
using namespace std;

int main()
{
    int a,b[5],sum;
    while(cin>>a)
    {
       sum=0;
       for(int i=0;i<=4;i++)
       {    cin>>b[i];
            if(b[i]<a)   sum+=b[i];
       }
       cout<<sum<<endl;
    }
    //system("pause"); 
    return 0;
}
